﻿#pragma once

#include "BaseShader.h"
#include <functional>

class OriginalShader : public BaseShader
{
	Q_OBJECT

public:
	/*static OriginalShader* Get()
	{
		static OriginalShader os;
		return &os;
	}*/
	OriginalShader(QObject* parent = nullptr);
	~OriginalShader();
private:
	
	//顶点着色器代码
	QString vertexSource = R"(
	attribute vec4 vertexIn;
	attribute vec2 textureIn;
	varying vec2 textureOut;
	void main(void)
	{
		gl_Position = vertexIn;
		textureOut = textureIn;
	}
	)";

	//片元着色器代码
	QString fragmentSource = R"(
	varying vec2 textureOut;
	uniform sampler2D tex_y;
	uniform sampler2D tex_u;
	uniform sampler2D tex_v;
	void main(void)
	{
		vec3 yuv;
		vec3 rgb;
		yuv.x = texture2D(tex_y, textureOut).r;
		yuv.y = texture2D(tex_u, textureOut).r - 0.5;
		yuv.z = texture2D(tex_v, textureOut).r - 0.5;
		rgb = mat3(1.0, 1.0, 1.0,
			0.0, -0.39465, 2.03211,
			1.13983, -0.58060, 0.0) * yuv;
		gl_FragColor = vec4(rgb, 1.0);
	}
	)";

};
